﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using KeRui.BLL;
using KeRui.Common;

public partial class Manage_Cms_Fieldlist : System.Web.UI.Page
{
    protected List<KeRui.Model.CmsModel> listCmsModel;
    protected List<KeRui.Model.CmsField> listCmsField;
    protected string show;
    protected void Page_Load(object sender, EventArgs e)
    {
        //登录判断
        ManageHelper.CheckAdminLogin();
        //权限判断
        ManageHelper.CheckAdminPower("system_fieldslist");
        KeRui.BLL.CmsModel bllCmsModel = new CmsModel();
        listCmsModel = bllCmsModel.GetList();
        KeRui.BLL.CmsField bllCmsField = new CmsField();
        show = PageRequest.GetString("show") == string.Empty ? "using" : PageRequest.GetString("show");
        switch (show)
        {
            case "all":
                listCmsField = bllCmsField.GetList("ModelID=" + (PageRequest.GetInt("modelid", -1) == -1 ? listCmsModel[0].ModelID : PageRequest.GetInt("modelid", -1)));
                break;
            case "using":
                listCmsField = bllCmsField.GetList("ModelID=" + (PageRequest.GetInt("modelid", -1) == -1 ? listCmsModel[0].ModelID : PageRequest.GetInt("modelid", -1)) + " AND IsUsing='True'");
                break;
        }
        switch (PageRequest.GetString("act"))
        {
            case "modshow":
                //显示权限hyc
                ManageHelper.CheckAdminPower("system_fieldslistshow");
                bllCmsField.ModifyIsUsing(PageRequest.GetInt("fieldid", -1));
                Response.Redirect(string.Format("FieldList.aspx?siteid={0}&modelid={1}&show={2}", PageRequest.GetInt("siteid", -1), PageRequest.GetInt("modelid", -1), PageRequest.GetString("show")));
                Response.End();
                break;
            case "delete":
                //删除权限
                ManageHelper.CheckAdminPower("system_fieldslistdelete");
                bllCmsField.Delete(PageRequest.GetInt("fieldid", -1));
                //删除日志
                ManageHelper.AddLog("system_fieldslistdelete", "删除了字段，ID为:" + PageRequest.GetInt("fieldid", -1));
                Response.Redirect(string.Format("FieldList.aspx?siteid={0}&modelid={1}&show={2}", PageRequest.GetInt("siteid", -1), PageRequest.GetInt("modelid", -1), PageRequest.GetString("show")));
                Response.End();
                break;
        }
    }
}